<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>																			
<%@ include file="/WEB-INF/view/jsp/base.jsp" %>																																			
<html lang="en">
<style>

</style>
<body>																																														
	<div id="content">																																										
			<div class="container-fluid">																																							
					<table id="" url="" class="mytable" style="margin:15px 0px;">																	
					  <thead>	
						<tr role="row">
							<th class="ui-state-default" role="columnheader" >	
								<div style="font-size:15px;">
									 注册中心地址:&nbsp;<strong><span id="ibmsUrl" style="font-size:15px;">XXX.XXX.XXX.XXX:YYYYY</span></strong>
									 &nbsp;&nbsp;&nbsp;&nbsp;状态:&nbsp;<strong><span id="ibmsStatus" style="font-size:15px;">启动|停止</span></strong>
									 &nbsp;&nbsp;&nbsp;&nbsp;动作:&nbsp; 
									 <button id="b_stop"  type="button" class="btn btn-mini btn-danger"  style="margin-bottom:5px;padding: 2px 25px;display:none;font-size:15px;" onclick="getIbmsInfo('ibms.sh stop \n')">停&nbsp;&nbsp;止</button>								
									 <button id="b_start" type="button" class="btn btn-mini btn-success" style="margin-bottom:5px;padding: 2px 25px;display:none;font-size:15px;" onclick="getIbmsInfo('ibms.sh start \n')">启&nbsp;&nbsp;动</button>
								</div>
							</th>
						</tr>
					  </thead>
					  <tbody>
						<tr style="display:none;"><td id="ibms_console" ></td></tr>					  
					  </tbody>	
					</table>						
					<div style="font-size:15px;padding:0px 5px 5px 5px;">
						<form id="registryListForm" url="" method="post" action="">
							<label style="display:inline;margin-bottom:10px;">会话节点:</label>
							<input  type="text" class="" name="sessionNode" placeholder="全部" size=""  maxlength="">
							<label style="display:inline"> &nbsp;&nbsp;远程地址:</label>
							<input   type="text" class="" name="remoteAdress" placeholder="全部" size=""  maxlength="">&nbsp;&nbsp;
							<button id="filter" type="button" class="btn btn-info" style="margin-bottom:5px;padding: 2px 5px;" onclick="load()">  &nbsp;&nbsp;过&nbsp;滤&nbsp;&nbsp;&nbsp;</button>
						</form>
					</div> 																																									
				<table id="registryListTable" url="" class="mytable">																	
					<thead>																																									
						<tr role="row">	 										
							<th class="ui-state-default" role="columnheader"  style="" name="localAdress" primaryKey="true" >本地地址</th> 																																				
							<th class="ui-state-default" role="columnheader"  style="" name="sessionTypeName" primaryKey="true" >会话类型</th> 										
							<th class="ui-state-default" role="columnheader"  style="" name="sessionNode">会话节点</th>					
							<th class="ui-state-default" role="columnheader"  style="" name="remoteAdress" primaryKey="true" >远程地址</th> 										
						</tr>																																								
					</thead>																																								
					<tbody id="registryListTable-tbody" role="alert" aria-live="polite" aria-relevant="all">																										
					</tbody>																																								
				</table>																																									
		</div>																																													
	</div>																																														
</body>																																														
<script type="text/javascript">																																						
$(document).ready(function(){
	
	init();
	//1分钟刷新一次
	setInterval(load,60*1000);
																																										
});	

function init(){
	getIbmsInfo("ibms.sh status \n");
}

function load(){
	$("#registryListForm").attr("action","<%=path%>/sysRunManage/getRegistryList");
	$("#registryListForm").ajaxSubmit(function(text){																															
	    if(text.success){																																								
			var data = text.data;
			var _data = data.data;
			var _ths = [];      //标题行
			var _primaryKey = [] ;  //唯一索引字段				
			$("#registryListTable").find("thead tr th").each(function(){
				var $this = $(this) ;
				_ths.push($this.attr("name"));
				if($this.attr("primaryKey")=="true"){
					_primaryKey.push($this.attr("name")) ;
				}
			});
			var tbody = loadData(_data,_ths,_primaryKey);
			$("#registryListTable").find("tbody").html(tbody);
		}
	});
}

function loadData(data,_ths,_primaryKey){
	var tbody = "";
	for(var i=0;i<data.length;i++){
		var tr = '<tr class="gradeA ">';
		for(var index in _ths){
			if(_ths[index]!="work-box"){
				var td_text = ((data[i][_ths[index]]==null)?"":data[i][_ths[index]]);
				tr+='<td class=" " >'+ td_text +'</td>';
			}else if(_ths[index]=="work-box"){
				tr+='<td class="center ">';
				tr+='<a href="#" onclick="edit($(this))"><span class="glyphicon glyphicon-pencil"></span></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" onclick="del($(this))"><span><span class="glyphicon glyphicon-remove"></span></span></a>';
				tr+='<form action="" method="post">';
				for(var key in _primaryKey){
					tr+='<input type="hidden" name="'+ _primaryKey[key] +'" value="'+ data[i][_primaryKey[key]] +'"/>';
				}
				tr+='</form>';
				tr+='</td>';
			}
		}
		 tr+='</tr>' ;
		 tbody+=tr;	 
	}
	return tbody ;
}

function getIbmsInfo(cmd){
	$.ajax({
		url:"<%=path%>/sysRunManage/getIbmsInfo",
		data:{"cmd":cmd},
		type:"post",
		success:function(text){
			var data =  text.data ;
			$("#ibmsUrl").html(data.ibmsUrl);
			$("#ibmsStatus").html(data.ibmsStatus?"启动":"停止");
			$("#ibms_console").html(data.console);
			if(data.ibmsStatus==true){
				$("#b_start").css("display","none");
				$("#b_stop").css("display","inline");
			}else{
				$("#b_stop").css("display","none");
				$("#b_start").css("display","inline");
			}
			load();
		}		
	});
}


																																			
</script>																																												
</html>	    																																												

